import { Module } from '@nestjs/common';
import { AppController } from './app.controller';
import { AppService } from './app.service';
// 导入模块
import { LoggerModule } from 'nestjs-pino';
import * as path from 'node:path';

@Module({
  imports: [
    LoggerModule.forRoot({
      // 增加配置
      pinoHttp: {
        transport: {
          // target: 'pino-pretty',
          // options: {
          //   colorize: true,
          // },
          targets: [
            {
              target: 'pino-pretty',
              options: {
                colorize: true,
              },
              level: 'debug',
            },
            {
              target: 'pino-roll',
              options: {
                file: path.join('logs', 'log.txt'),
                frequency: 'daily',
                mkdir: true,
                size: '0.2k',
              },
              level: 'debug',
            },
          ],
        },
      },
    }),
  ],
  controllers: [AppController],
  providers: [AppService],
})
export class AppModule {}
